<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<title>用户管理</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<style type="text/css">
		.actived{color:red;}
		</style>
		<%@ include file="/WEB-INF/jspf/taglibs.jspf"%>
		<%@ include file="/WEB-INF/jspf/statics.jspf"%>
	</head>
<body>
		<%@include file="/WEB-INF/pages/common/header.jsp" %>
		<%@include file="/WEB-INF/pages/common/menu.jsp" %>
		<div id="rightqqqq" style="float:left;width:88%;height:10px;margin-left:4px;min-height:80%;overflow-y:auto; overflow-x:hidden; ">
					<div style="float: left; width: 99%; height: auto; min-height: 100%; border-left-style:groove;">
		<div style="margin-top:10px;height:auto;">
			 <div id="navContainer" class="navC mb10">  
		        <ul>  
		            <li class="current"><a onclick="userList();" hidefocus="true">用户管理</a></li>  
		            <li><a  onclick="addUser();" hidefocus="true">用户添加</a></li>  
		        </ul>  
   			 </div>  
			</div>
			<div style="float: left; width: 99%; height:auto;">	
			<!--div-958 start-->
			<div class="div-958" style="margin-top: 0px; width: 100%">
				<div style="width: 100%;" class="container clearfix w942">
					<div style="width: 100%;" class="cont bl0">
                        <div class="content">
                            <form id="searchForm" style="padding-bottom:20px;display:none;"
                                  onsubmit="fnValidate('#startOrderTime','#endOrderTime');$('#dataTable').refreshData();return false;">
                            </form>
                            <div class="orderResults" ng-show="orderForm .searchFlag">
                                <div class="table-toolbar pusht">
                                    <div class="btn-group right toggle-content">
                                        <a class="" href="#">
                                        	    更改列显示
                                        </a>
                                        <div class="dropdown-menu twin-cols-dropdown-menu" id="column-edit-01"></div>
                                    </div>
                                </div>
                                <div id="dataTable_wrapper" class="dataTables_wrapper" role="grid" >
                                    <div class="top">
                                        <div class="dataTables_info" id="dataTable_info">查询结果</div>
                                    </div>
                                    <table id="dataTable" class="dataTable" aria-describedby="dataTable_info">
                                        <thead>
                                        <tr role="row">
                                        	<th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1">编号</th>
                                            <th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1">姓名</th>
                                            <th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1">等级</th>
                                            <th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1">电话</th>
                                            <th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1">身份证</th>
                                            <th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1">部门</th>
                                            <th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1">添加时间</th>
                                            <th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1">操作</th>
                                        </tr>
                                        </thead>
                                        <tbody role="alert" aria-live="polite" aria-relevant="all">
                                        </tbody>
                                    </table>
                                </div>
         
                            </div>
                        </div>
								</div>
							</div>
						</div>
					</div>
				</div></div>
				<input type="hidden" id="success" onclick="showMessage('success');">
				<input type="hidden" id="fail" onclick="showMessage('fail');">
	</body>
</html>
<script type="text/javascript" src="<%=basePath %>/js/ui/jquery-ui-1.10.3.datepicker_zh_CN.js"></script>
<script type="text/javascript" src="<%=basePath %>/js/ui/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript">
	$().ready(function(){
		$('#navigation').accordion({
			header: '.head',
			navigation1: true, 
			event: 'click',
			autoHeight:true,
			active:3,
			animated: 'bounceslide'
		});
		$("a[class='actived']").removeAttr("class");
		$("#manageUsers").attr("class", "actived");
		$("#currentPosition").text("当前位置：企业管理 > 用户管理");
	});
	
    $(document).ready(function () {
     	$("#startOrderTime").datepicker().val();
        $("#endOrderTime").datepicker().val();
        $("#startVisitTime").datepicker().val();
        $("#endVisitTime").datepicker().val();
        search();
    })
    
    function userList(){
    	search();
    }
    function addUser(){
    	var str_href = "${ctx}/account/update_user/add";
    	dialog_iframe({url: str_href, title: "添加用户", width: 560, height: 380});
    }
    
    function deleteUser(userid){
    	Showbo.Msg.confirm("确认删除吗？",function(btn){
	    	$.post("${ctx}/account/delete_user",{userid:userid},function(data){
	    		if("success"==data){
					Showbo.Msg.alert("删除成功！");
					search();
	    		}else{
	    			Showbo.Msg.alert("删除失败！");
	    		}
	    	});
    	});
    }
    
    function showMessage(result){
    	if(result=="success"){
    		Showbo.Msg.alert('操作成功!');	
    		search();
    	}else{
    		Showbo.Msg.alert('操作失败!');
    	}
    }
    
    function search() {
    	$(".dropdown-menu").empty();
        	$(".toggle-content").hover(function () {
            $(this).find(".dropdown-menu").show();
        }, function () {
            $(this).find(".dropdown-menu").hide();
        });
        $("#dataTable").dataTables({
            "sAjaxSource": "${ctx }/account/search_user_list",
            "fnServerData": function (sSource, aoData, fnCallback) {
             	var postData = aoData.concat($("#searchForm").serializeArray());
                $.post(sSource, postData,function (json) {
                    fnCallback(json.data);
                }, "json");
            },
            "aoColumns": [
            	{
                    "sName": "login_name", "mDataProp": "loginName", "bSortable": false
                },
                {
                    "sName": "real_name", "mDataProp": "realName", "bSortable": false
                },
                {
                    "sName": "role_id", "mDataProp": "roleId", "bSortable": false
                },
                {
                    "sName": "phone_num", "mDataProp": "phoneNum", "bSortable": false
                },
                {
                    "sName": "identity_card", "mDataProp": "identityCard", "bSortable": false
                },
                {
                    "sName": "department_id", "mDataProp": "departmentId", "bSortable": false
                },
                {
                    "sName": "add_time", "mDataProp": "addTimeStr", "bSortable": false
                },
                {
                    "mDataProp": function (aData, type, val) {
                       // return val = '<a class="link_detail" onclick="updateUser('+aData.id+')" target="_blank">编辑</a>'+'|&nbsp;<a class="link_detail" onclick="deleteUser('+aData.id+')">删除</a>';
                    	 return val = '<a class="link_detail" onclick="deleteUser('+aData.id+')">删除</a>';
                    }, 
                    "sName": "id", "bSortable": false
                }
            ]
        });
         $("#dataTable").columnManager({"listTargetID": "column-edit-01"});
    }
</script>